function getCode(e) {
    checkPhone(); //验证手机号码
}

function getCode2(e) {
    resetCode(); //倒计时
}

function sendCode(e) {
    send(); //验证手机号码
    if (isPhone) {
        //resetCode(); //倒计时
        // return true;

        //发送验证码 返回成功后启用倒计时



    }
}
//发送验证码按钮触发
function send() {
    var phone = $('#phone').val();
    var pattern = /^1[0-9]{10}$/;
    isPhone = 1;
    if (phone == '') {
        layer.open({
            content: '请输入手机号码',
            className: 'popuo-login',
            skin: 'msg',
            time: 20 //2秒后自动关闭
        });
        isPhone = 0;
        return false;
    } else if (!pattern.test(phone)) {
        layer.open({
            content: '请输入正确的手机号码',
            className: 'popuo-login',
            skin: 'msg',
            time: 2 //2秒后自动关闭
        });
        isPhone = 0;
        return false;
    } else {
        return true;
    }
}
//验证手机号码
function checkPhone() {
    var phone = $('#phone').val(); //手机号
    var pwd = $('#pass1').val();
    var pwd_1 = $('#pass2').val();
    var pwd_2 = $('.pass2').val();
    var code = $('#code').val(); //验证码
    var pattern = /^1[0-9]{10}$/; //手机号格式
    var patrn = /^(\w){6,20}$/; //密码格式
    isPhone = 1;
    if (phone == '') {
        layer.open({
            content: '请输入手机号码',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        isPhone = 0;
        return false;
    }
    if (!pattern.test(phone)) {
        layer.open({
            content: '请输入正确的手机号码',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        isPhone = 0;
        return false;
    }
    if (code == '') {
        layer.open({
            content: '验证码四位有效验证码',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        return false;
    }
    if (pwd == '' || pwd_1 == '') {
        layer.open({
            content: '密码不能不为空',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        return false;
    }
    if (!patrn.test(pwd)) {
        layer.open({
            content: '请确认密码为6-20位数字或者字母其禁止包括特殊字符！',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        isPhone = 0;
        return false;
    }
    /*if(pwd_2 != pwd_1){
        layer.open({
            content: '请确认，两次密码是不输入一致！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }*/

    return true;
}
//修改密码
function yzeditpwd() {
    var pwd = $('#pass1').val();
    var pwd_1 = $('#pass2').val();
    var pwd_2 = $('.pass2').val();
    var code = $('#code').val();
    var patrn = /^(\w){6,20}$/;
    isPhone = 1;
    if (code == '') {
        layer.open({
            content: '请输入有效验证码验证码！',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        return false;
    }
    if (pwd == '' || pwd_1 == '') {
        layer.open({
            content: '密码不能不为空！',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        return false;
    }
    if (!patrn.test(pwd)) {
        layer.open({
            content: '请确认密码为6-20位数字或者字母其禁止包括特殊字符！',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        isPhone = 0;
        return false;
    }
    if (pwd_2 != pwd_1) {
        layer.open({
            content: '请确认，密码是否输入一致',
            className: 'popuo-login',
            skin: 'msg',
            time: 2
        })
        return false;
    }

    return true;
}
//倒计时
// function resetCode(){
//     $('#J_getCode').html('60');
//     // $('#J_second').html('60');
//     // $('#J_resetCode').show();
//     var second = 60;
//     var timer = null;
//     timer = setInterval(function(){
//         second -= 1;
//         if(second >0 ){
//             $('#J_second').html(second);
//         }else{
//             clearInterval(timer);
//             $('#J_getCode').show();
//             $('#J_resetCode').hide();
//         }
//     },1000);
// }
//点击多选框切换text和password的隐藏和显示
function showHidePassword() {
    $("#text").toggle();
    $("#text1").toggle();
    $(".judge").toggle();
    $(".judge1").toggle();
}
//text框失去焦点把text框的值赋值给password框
function textBlur() {
    $(".judge").val($("#text").val());
    $(".judge1").val($("#text1").val());
}
//password框失去焦点把password框的值赋值给text框
function passwordBlur() {
    $("#text").val($(".judge").val());
    $("#text1").val($(".judge1").val());
}
//判断是不显示密码
$('body').on('click', '#togglePassword', function() {
        $(this).toggleClass("active");
    })
    //清空手机号
function textclean() {
    var txtclean = document.getElementById("phone");
    txtclean.value = "";
}
